<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="content">
            <div align="center" >
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <div align="center" style="width: 80%">
                    
                    <h:form styleClass="jsfcrud_list_form">
                        <p:panel header="Comentários Cadastrados">
                            <h:outputText escape="false" value="#{bundle.ListComentariosEmpty}" rendered="#{comentariosController.items.rowCount == 0}"/>
                            <h:panelGroup rendered="#{comentariosController.items.rowCount > 0}">
                                <h:outputText value="#{comentariosController.pagination.pageFirstItem + 1}..#{comentariosController.pagination.pageLastItem + 1}/#{comentariosController.pagination.itemsCount}"/>&nbsp;
                                <p:commandButton ajax="false" process="@this"  action="#{comentariosController.previous}" value="#{bundle.Previous} #{comentariosController.pagination.pageSize}" rendered="#{comentariosController.pagination.hasPreviousPage}"/>&nbsp;
                                <p:commandButton ajax="false" process="@this"  action="#{comentariosController.next}" value="#{bundle.Next} #{comentariosController.pagination.pageSize}" rendered="#{comentariosController.pagination.hasNextPage}"/>&nbsp;
                                <h:dataTable value="#{comentariosController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListComentariosTitle_comentario}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.comentario}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListComentariosTitle_dtComentario}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.dtComentario}">
                                            <f:convertDateTime pattern="dd/MM/yyyy" />
                                        </h:outputText>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListComentariosTitle_idUsuario}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.idUsuario.nome}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="#{bundle.ListComentariosTitle_idforum}"/>
                                        </f:facet>
                                        <h:outputText value="#{item.idforum.assunto}"/>
                                    </h:column>
                                    <h:column>
                                        <f:facet name="header">
                                            <h:outputText value="Opções"/>
                                        </f:facet>
                                        <p:commandButton ajax="false" process="@this"  action="#{comentariosController.prepareView}" icon="ui-icon-plusthick"/>
                                        <h:outputText value=" "/>
                                        <p:commandButton ajax="false" process="@this"  action="#{comentariosController.prepareEdit}" icon="ui-icon-pencil"/>
                                        <h:outputText value=" "/>
                                        <p:commandButton ajax="false" process="@this"  action="#{comentariosController.destroy}" icon="ui-icon-trash" />
                                    </h:column>
                                </h:dataTable>
                            </h:panelGroup>
                            <br />
                            <p:commandButton ajax="false" process="@this"  action="#{comentariosController.prepareCreate}" value="#{bundle.ListComentariosCreateLink}"/>
                            <br />
                            <br />
                            <h:link outcome="/index" value="#{bundle.ListComentariosIndexLink}"/>
                        </p:panel>
                    </h:form>
                    
                </div>
            </div>
        </ui:define>
    </ui:composition>

</html>
